# Maintainer: Christoph Reiter <reiter.christoph@gmail.com>

_realname=setuptools-scm
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=7.1.0
pkgrel=3
pkgdesc='Handles managing your python package versions in scm metadata (mingw-w64)'
url='https://github.com/pypa/setuptools_scm'
license=('MIT')
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
depends=("${MINGW_PACKAGE_PREFIX}-python-packaging"
         "${MINGW_PACKAGE_PREFIX}-python-setuptools"
         "${MINGW_PACKAGE_PREFIX}-python-typing_extensions")
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname/-/_}-${pkgver}.tar.gz")
sha256sums=('6c508345a771aad7d56ebff0e70628bf2b0ec7573762be9960214730de278f27')

prepare() {
  cd "${srcdir}"
  rm -rf python-build-${MSYSTEM} | true
  cp -r "${_realname/-/_}-${pkgver}" "python-build-${MSYSTEM}"
}

build() {
  msg "Python build for ${MSYSTEM}"
  cd "${srcdir}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build
}
